import {IRequestError} from "./request";


/**
 * 请求头常量
 */
export const HEADER = {
    ContentType: 'Content-Type', // 内容类型
    Authorization: 'Authorization' // 授权信息
}

/**
 * 内容类型常量
 */
export const CONTENT_TYPE = {
    ApplicationJson: 'application/json', // JSON格式
    ApplicationWWW: 'application/x-www-form-urlencoded', // 表单格式
    TextHtml: 'text/html', // HTML格式
    FromData: 'multipart/form-data', // 多部分表单数据
}
/**
 * 响应类型常量
 */
export const RESPONSE_TYPE: Record<string, XMLHttpRequestResponseType> = {
    Empty: '', // 空响应
    Json: 'json', // JSON格式
    Text: 'text', // 文本格式
    Document: 'document', // 文档格式
    Blob: 'blob', // Blob格式
    Arraybuffer: 'arraybuffer', // 二进制数组格式
}

/**
 * 请求方法常量
 */
export const METHOD = {
    Get: 'GET', // GET请求
    Post: 'POST', // POST请求
    Delete: 'DELETE', // DELETE请求
    Put: 'PUT', // PUT请求
}

/**
 * 请求错误常量
 */
export const ERROR: IRequestError = {
    err_400: {code: 400, msg: "400 Data Error"},
    err_401: {code: 401, msg: "401 Unauthorized"},
    err_404: {code: 404, msg: "404 Not Found"},
    err_405: {code: 405, msg: "405 Method Not Allowed"},
    err_406: {code: 406, msg: "406 Not Acceptable"},
    err_407: {code: 407, msg: "407 Proxy Authentication Required"},
    err_408: {code: 408, msg: "408 Request Timeout"},
    err_409: {code: 409, msg: "409 Conflict"},
    err_412: {code: 412, msg: "412 Precondition Failed"},
    err_413: {code: 413, msg: "413 Content Too Large"},
    err_414: {code: 414, msg: "414 URI Too Long"},
    err_415: {code: 415, msg: "415 Unsupported Media Type"},
    err_416: {code: 416, msg: "416 Range Not Satisfiable"},
    err_417: {code: 417, msg: "417 Expectation Failed"},
    err_500: {code: 500, msg: "500 Internal Server Error"},
    err_501: {code: 501, msg: "501 Not Implemented"},
    err_502: {code: 502, msg: "502 Bad Gateway"},
    err_503: {code: 503, msg: "503 Service Unavailable"},
    err_504: {code: 504, msg: "504 Gateway Timeout"},
    err_505: {code: 505, msg: "505 HTTP Version Not Supported"},
    err_507: {code: 507, msg: "507 Insufficient Storage"},
    err_508: {code: 508, msg: "508 Loop Detected"},
    err_510: {code: 510, msg: "510 Not Extended"},
    err_511: {code: 511, msg: "511 Network Authentication Required"},
    err_10000: {code: 10000, msg: "Unknown error"}
}
